<form action="<?php echo base_url();?>/index.php/admin/option" method="POST" id="profile-form">
<article class="width_half module" style="margin-bottom: 20px;">
	<header>
		<h3 style="width: 50%;">Option</h3>
	</header>
	<div class="module_content">
		<?php foreach ($option as $key) : ?>
		<fieldset>
			<label>Bắt đầu đăng ký</label>
			<input type="text" name="fromdate" placeholder="yyyy-mm-dd" value="<?php echo date('Y-m-d',strtotime($key->startdate));?>" style="width:40%;" id="fromdate">
		</fieldset>
		<fieldset>
			<label>Kết thúc đăng ký</label>
			<input type="text" name="todate" placeholder="yyyy-mm-dd" value="<?php echo date('Y-m-d',strtotime($key->enddate));?>" style="width:40%;" id="todate">
		</fieldset>
		<fieldset>
			<label>Số lượng công ty tối đa</label>
			<input type="text" name="trainee" value="<?php echo $key->trainee;?>" style="width:40%;">
		</fieldset>
	<?php endforeach; ?>
	</div>
	<footer>
		<div class="submit_link">
			<input type="submit" value="Change" class="alt_btn"/>
			<input type="reset" value="Clear"/>
		</div>
	</footer>
</article>
</form>
<script>
$(function() {
	$("#fromdate").datepicker({
		dateFormat: 'yy-mm-dd',
		maxDate: new Date(<?php echo $option->enddate*1000;?>),
		onSelect: function (selectedDateTime){
			var start = $(this).datepicker('getDate');
			
			$('#todate').datepicker('option', 'minDate', new Date(start.getTime()));
		}
	});
	$("#todate").datepicker({
		dateFormat: 'yy-mm-dd',
		minDate: new Date(<?php echo $option->startdate*1000;?>),
		onSelect: function (selectedDateTime){
			var end = $(this).datepicker('getDate');
			$('#fromdate').datepicker('option', 'maxDate', new Date(end.getTime()));
		}
	});
	
});
</script>